package edu.zut.cs.javaee.manager.department.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
import org.springframework.data.domain.ExampleMatcher.StringMatcher;
import org.springframework.stereotype.Service;

import edu.zut.cs.javaee.manager.base.service.impl.GenericManagerImpl;
import edu.zut.cs.javaee.manager.department.dao.LeadershipDao;
import edu.zut.cs.javaee.manager.department.domain.Department;
import edu.zut.cs.javaee.manager.department.domain.Leadership;
import edu.zut.cs.javaee.manager.department.service.LeadershipManager;
@Service(value="leadershipManager")
public class LeadershipManagerimpl extends GenericManagerImpl<Leadership,Long> implements LeadershipManager{

	 LeadershipDao leadershipDao;

	@Autowired
	public void setLeadershipDao(LeadershipDao leadershipDao) {
		this.leadershipDao = leadershipDao;
		this.dao=this.leadershipDao;
	}

	@Override
	public List<Leadership> findByName(String leadership_name) {
		Leadership querydepart=new Leadership();
		querydepart.setLeader_name(leadership_name);
		ExampleMatcher matcher = ExampleMatcher.matching() // 构建对象
				.withStringMatcher(StringMatcher.CONTAINING) // 改变默认字符串匹配方式：模糊查询
				.withMatcher("leadership_name", GenericPropertyMatchers.contains()) //采用“开始匹配”的方式查询
				.withIgnorePaths("dateCreated", "dateModified"); // 忽略属性：是否关注。因为是基本类型，需要忽略掉
		// 创建实例并查询
		Example<Leadership> ex = Example.of(querydepart, matcher);
		List<Leadership> result=this.leadershipDao.findAll(ex);
		return result;
	}

	@Override
	public List<Leadership> findByGrade(String leader_grade) {
		Leadership querydepart=new Leadership();
		querydepart.setLeader_name(leader_grade);
		ExampleMatcher matcher = ExampleMatcher.matching() // 构建对象
				.withStringMatcher(StringMatcher.CONTAINING) // 改变默认字符串匹配方式：模糊查询
				.withMatcher("leader_grade", GenericPropertyMatchers.contains()) //采用“开始匹配”的方式查询
				.withIgnorePaths("dateCreated", "dateModified"); // 忽略属性：是否关注。因为是基本类型，需要忽略掉
		// 创建实例并查询
		Example<Leadership> ex = Example.of(querydepart, matcher);
		List<Leadership> result=this.leadershipDao.findAll(ex);
		return result;
	}

	@Override
	public List<Leadership> findByTel(String leader_tel) {
		// TODO Auto-generated method stub
		return null;
	}
	 

	
}
